var export_to=App.ShowFileDialog(false, "", "");
if( export_to.length )
{
	Include(App.AppPath+"\\mode\\markdown\\Markdown.Converter.js")
	Include(App.AppPath+"\\mode\\markdown\\Markdown.Extra.js")

	var doc=App.ActiveDoc;
	var text = doc.Text

	var converter = new Markdown.Converter();
	Markdown.Extra.init(converter);
	var html = converter.makeHtml(text);

	var file = new ActiveXObject("Adodb.Stream");
	file.Type = 2;
	file.Open();
	file.Charset = "utf-8";

	var css=App.AppPath+"\\mode\\markdown\\" + "default.css";
	var prettify_js=App.AppPath+"\\mode\\markdown\\" + "prettify.js";
	var prettify_css=App.AppPath+"\\mode\\markdown\\" + "prettify.css";
	var jquery_js=App.AppPath+"\\mode\\markdown\\" + "jquery-1.10.2.min.js";

	var header="<html>\n\
	<!doctype html public '-//W3C//DTD HTML 4.0 Transitional //EN'>\n\
	<head>\n\
	<title>Markdown Preview of EverEdit</title>\n\
	<meta name='generator' content='EverEdit' />\n\
	<link href='" + css + "' rel='stylesheet'></link>\n\
	<link href='" + prettify_css + "' rel='stylesheet'></link>\n\
	<script type='text/javascript' src='" + prettify_js + "'></script>\n\
	<script type='text/javascript' src='" + jquery_js + "'></script>\n\
	</head>\n\
	<body>\n";

	var footer="\n\
	<script type='text/javascript'>\n\
	$(document).ready(function(){\n\
	  if($('code').length>0){\n\
	    $('code').parent().addClass('prettyprint');\n\
	    prettyPrint();\n\
	};\n\
	});\n\
	</script>\n\
	</body>\n\
	</html>";

	file.WriteText(header);
	file.WriteText(html);
	file.WriteText(footer);
	file.SaveToFile(export_to,2);
	file.Close();

	var msg="Saved to [" + export_to + "]";
	App.ShowMsgBox( msg, "Markdown2Html", 64);
}
